package weaver.jobs.cese;

import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.interfaces.schedule.BaseCronJob;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Title: ecology
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-10-30
 * @Description: 定时更新失效的验证码的状态
 * @ModifyLog:
 **/

public class WeaCodeInvalidCronJob extends BaseCronJob {
    @Override
    public void execute() {
        BaseBean baseBean = new BaseBean();
        baseBean.writeLog( "-----------WeaCodeInvalidCronJob------------" );
        Date now = new Date();
        Date now_5 = new Date(now.getTime() - 5*60000); //1分钟前的时间
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
        String nowTime_5 = dateFormat.format(now_5);
        baseBean.writeLog("5分钟前："+nowTime_5);
        String curtime = DateUtil.getFullDate();
        baseBean.writeLog("当前时间："+curtime);
        RecordSet rs = new RecordSet();
        String sql = "update uf_smscode set status = '1' where status = '0' and systemdate<='"+nowTime_5+"'";
        baseBean.writeLog(sql);
        rs.executeUpdate( sql );
    }

}
